package com.rwb.springboot.sell.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * Created by ruwenbo on 2018/1/6.
 */
@RestController
@RequestMapping("/weixin")
public class WeixinController {

    @GetMapping("/auth")
    public void auth(@RequestParam("code") String code) {
        System.out.println("进入auth方法...");
        System.out.println("code= " + code);

        String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx7ad9c637c26ea111&secret=a6387d3898f07ea83cb756be0b366399&code="+ code +"&grant_type=authorization_code";
        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);
        System.out.println(response);

    }

}
